import Vue from 'vue'
import VueRouter from 'vue-router'
import Index from '../views/Index.vue'

Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        name: 'Index',
        component: Index,
        meta: {
            title: 'message.term.index',
        },
        children: [{
            path: '/court-address',
            name: 'CourtAddress',
            meta: {
                title: 'message.term.court_address',
            },
<<<<<<< HEAD
            component: () => import('@/views/court-address/CourtAddress.vue')
        }, {
            path: '/litigation-common-calculator',
            name: 'LitigationCommonCalculator',
            meta: {
                title: 'message.term.litigation_common_calculator',
            },
            component: () => import('@/views/litigation-common-calculator/LitigationCommonCalculator.vue')
        },{
                path: '/m-interbank-offered-rate',
                name: 'm-interbank-offered-rate-kits',
                meta: {
                    title: 'message.term.interbank_offered_rate_kits',
                },
                component: () => import('@/views/litigation-common-calculator/m-interbank-offered-rate.vue')
            },{
                path: '/lawyers-fee',
                name: 'lawyers-fee-kits',
                meta: {
                    title: 'message.term.lawyer_fees_level_calculator',
                },
                component: () => import('@/views/litigation-common-calculator/lawyers-fee.vue')

        },{
            path: '/day',
            name: 'day-kits',
            meta: {
                title: '天数日期计算工具'
            },
            component: () => import('@/views/litigation-common-calculator/day.vue')
        },{
            path: '/legal-costs',
            name: 'legal-costs-kits',
            meta: {
                title: 'message.term.legal_costs_calculator',
            },
            component: () => import('@/views/litigation-common-calculator/legal-costs.vue')
        }]
=======
           component: () => import('@/views/court-address/CourtAddress.vue')
        }, /*{
            path: '/lawsuit',
            name: 'lawsuit',
            meta: {
                title: 'message.term.lawsuit',
            },
            component: () => import('@/views/step/lawsuit/lawsuit.vue')
        },*/
            {
                path: '/step/:docType',
                name: 'step',
                meta: {
                    title: '步骤'
                },
                component: (resolve) => require(['@/views/step/step.vue'], resolve),
                children: [
                    {
                        path: 'civil',
                        name: 'civil',
                        meta: {
                            title: 'message.term.civil',
                        },
                        component: () => import('@/views/step/civil/civil.vue')
                    }, {
                        path: 'lawsuit',
                        name: 'lawsuit',
                        meta: {
                            title: 'message.term.lawsuit',
                        },
                        component: () => import('@/views/step/lawsuit/lawsuit.vue')
                    },
                    {
                        path: 'doc-filter',
                        name: 'doc-filter',
                        component: (resolve) => require(['@/views/step/doc-filter-picker.vue'], resolve),
                        meta: {
                            title: '筛选文件'
                        }
                    }, {
                        path: 'doc',
                        name: 'doc',
                        component: (resolve) => require(['@/views/step/doc-picker.vue'], resolve),
                        meta: {
                            title: '选择文件'
                        }
                    }, {
                        path: 'form',
                        name: 'form',
                        component: (resolve) => require(['@/views/step/form.vue'], resolve),
                        meta: {
                            title: '填写信息'
                        }
                    }, {
                        path: 'confirm',
                        name: 'confirm',
                        component: (resolve) => require(['@/views/step/confirm.vue'], resolve),
                        meta: {
                            title: '预览并确认'
                        }
                    }, {
                        path: 'pay/:orderSN',
                        name: 'pay',
                        component: (resolve) => require(['@/views/step/pay.vue'], resolve),
                        meta: {
                            title: '支付'
                        }
                    }, {
                        path: 'delivery/:orderSN',
                        name: 'success',
                        component: (resolve) => require(['@/views/success.vue'], resolve),
                        meta: {
                            title: '发送'
                        }
                    }]
            }]
>>>>>>> 20a254d (front)
    },
    {
        path: '/about',
        name: 'About',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
    }
<<<<<<< HEAD
]

const router = new VueRouter({
    // mode: 'history',
=======

]

const router = new VueRouter({
    mode: 'history',
>>>>>>> 20a254d (front)
    base: process.env.BASE_URL,
    routes
})

/**
 * 当跳转页面的时候，把还在等待提交的请求全部终止，有利于提升性能
 */
router.beforeEach((to, from, next) => {
    // 切换路由时清空上个路由未完成的所有请求
    if (Vue.prototype.__axiosPromiseRequestArray) {
        Vue.prototype.__axiosPromiseRequestArray.forEach((cancel) => {
            cancel();
        });
        Vue.prototype.__axiosPromiseRequestArray.length = 0;
    }

    next();
})

export default router
